package com.sina.auto.components.WebCaptureImpl;

import org.openqa.selenium.JavascriptExecutor;
import org.openqa.selenium.chrome.ChromeDriver;

class ScrollWindow {

    static void scroll(ChromeDriverEx driver){
        //拉滚动条到最底部
        String height = String.valueOf(((JavascriptExecutor) driver).executeScript("return document.body.scrollHeight"));
        for(int i = 75; i<Integer.valueOf(height);i+=75){
            ((JavascriptExecutor) driver).executeScript("scrollTo(0," + String.valueOf(i) + ")");
        }
        ((JavascriptExecutor) driver).executeScript("scrollTo(0," + String.valueOf(0) + ")");
    }

    static void scroll(ChromeDriver driver){
        //拉滚动条到最底部
        String height = String.valueOf(((JavascriptExecutor) driver).executeScript("return document.body.scrollHeight"));
        for(int i = 100; i<Integer.valueOf(height);i+=100){
            ((JavascriptExecutor) driver).executeScript("scrollTo(0," + String.valueOf(i) + ")");
        }
        ((JavascriptExecutor) driver).executeScript("scrollTo(0," + String.valueOf(0) + ")");
    }
}
